package com.ck.javacode.Chapter7;

/**
 * @author: caoke
 * @date: 2021/12/5 6:40 下午
 * @description:
 */
public class D9_Constructor01 {
    public static void main(String[] args) {
        Persons p1 = new Persons("smith");
        Persons p2 = new Persons("smith");
        System.out.println("p1 的信息如下");
        System.out.println("p1 的hashcode"+p1.hashCode());
        System.out.println("p2 的hashcode"+p2.hashCode());
        System.out.println("p1 对象 name=" + p1.name);//smith
        System.out.println("p1 对象 age=" + p1.age);//80


    }
}
class Mt{

    /*
    默认构造器
    Mt() {

    }
     */
}

class Persons{
    String name;
    int age;

    public Persons(){
        age=18;
    }

    public Persons(String name,int age){
        System.out.println("构造器被调用~~ 完成对象的属性初始化");
        // this.name 就是当前对象的属性
        this.name = name;
        this.age = age;
        System.out.println("this 的hashcode"+this.hashCode());
    }

    public Persons(String Name){
        System.out.println("构造器被调用~~ 完成对象的属性初始化");
        name = Name;
        System.out.println("this 的hashcode"+this.hashCode());
    }


}